package com.example.utils;

import java.security.SecureRandom;

import lombok.experimental.UtilityClass;

@UtilityClass
public class CaptchaUtil {

    private static final String NUMBERS = "0123456789";
    private static final int CAPTCHA_LENGTH = 6;

    public String generateCaptcha() {
        SecureRandom random = new SecureRandom();
        StringBuilder captcha = new StringBuilder(CAPTCHA_LENGTH);

        for (int i = 0; i < CAPTCHA_LENGTH; i++) {
            int randomIndx = random.nextInt(NUMBERS.length());
            captcha.append(NUMBERS.charAt(randomIndx));
        }

        return captcha.toString();
    }

}
